<!DOCTYPE html>
<title>Element#requestFullscreen() followed by moving the element within the document</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<div id="log"></div>
<div id="target"></div>
<div id="moveto"></div>
<script>
async_test(t => {
  const target = document.getElementById("target");
  const moveTo = document.getElementById("moveto");

  document.onfullscreenchange = t.step_func_done(() => {
    assert_equals(document.fullscreenElement, target);
    assert_equals(target.parentNode, moveTo);
  });
  document.onfullscreenerror = t.unreached_func("fullscreenerror event");

  trusted_click(t, () => {
    target.requestFullscreen();
    moveTo.appendChild(target);
  }, document.body);
});
</script>
